<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <link rel="stylesheet" th:href="@{/lib/lui/css/layui.css}">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>
<div class="layui-container">
<div th:html="${teacher.id}"></div>
<div th:if="${edit}">
</div>
<form id="teacherForm" class="layui-form" action="edit" method="post">
    <input type="hidden" name="id" th:value="${teacher.id}"/>
     
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div th:if="${edit}" class="layui-input-block">
            <input  type="text" name="name" lay-verify="title" autocomplete="off" th:value="${teacher.name}" placeholder="请输入姓名" class="layui-input">
        </div>
        <div class="layui-form-mid" th:unless="${edit}" th:text="${teacher.name}"></div>
    </div>
    
    <div class="layui-form-item">
        <label class="layui-form-label">所属驾校</label>
        <div th:if="${edit}" class="layui-input-block">
            <input  type="text" name="belongId" lay-verify="title" autocomplete="off" th:value="${teacher.belongId}" placeholder="请输入所属驾校" class="layui-input">
        </div>
        <div class="layui-form-mid" th:unless="${edit}" th:text="${teacher.belongId}"></div>
    </div>

	<div class="layui-form-item">
        <label class="layui-form-label">教龄</label>
        <div th:if="${edit}" class="layui-input-block">
            <input  type="text" name="teachingAge" lay-verify="title" autocomplete="off" th:value="${teacher.teachingAge}" placeholder="请输入教龄" class="layui-input">
        </div>
        <div class="layui-form-mid" th:unless="${edit}" th:text="${teacher.teachingAge}"></div>
    </div>
    
    <div class="layui-form-item">
        <label class="layui-form-label">标签</label>
        <div th:if="${edit}" class="layui-input-block">
            <input  type="text" name="tag" lay-verify="title" autocomplete="off" th:value="${teacher.tag}" placeholder="请输入标签" class="layui-input">
        </div>
        <div class="layui-form-mid" th:unless="${edit}" th:text="${teacher.tag}"></div>
    </div>
    
    <div class="layui-form-item">
        <label class="layui-form-label">头像</label>
        <div th:if="${edit}" class="layui-input-block">
        	<img src="/demo/img/9.png">    
        </div>
    </div>
    
    <div class="layui-form-item">
        <label class="layui-form-label">教学地址</label>
        <div th:if="${edit}" class="layui-input-block">
            <input  type="text" name="address" lay-verify="title" autocomplete="off" th:value="${teacher.address}" placeholder="请输入教学地址" class="layui-input">
        </div>
        <div class="layui-form-mid" th:unless="${edit}" th:text="${teacher.address}"></div>
    </div>
    
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">简介</label>
        <div th:if="${edit}" class="layui-input-block">
            <textarea class="layui-textarea" name="introduce" th:text="${teacher.introduce}">
            </textarea>
        </div>
        <div class="layui-form-mid" th:unless="${edit}" th:text="${teacher.introduce}"></div>
    </div>
    
</form>
</div>
<script th:src="@{/lib/jquery/jquery.js}"></script>
<script th:src="@{/lib/jquery/jquery.forms.js}"></script>
<script th:src="@{/lib/lui/layui.all.js}"></script>
<script type="text/javascript">
    $.fn.serializeObject = function()
    {
        var o = {};
        var a = this.serializeArray();
        $.each(a, function() {
            if (o[this.name] !== undefined) {
                if (!o[this.name].push) {
                    o[this.name] = [o[this.name]];
                }
                o[this.name].push(this.value || '');
            } else {
                o[this.name] = this.value || '';
            }
        });
        return o;
    };
</script>
<script type="text/javascript">
    layui.laydate.render({
        elem: '#date'
    });
    //layui.layedit.build('LAY_demo_editor');

    function doSave(fn){

        var data = $("#teacherForm").serializeObject();

        $.ajax("edit",{
            method:"post",
            contentType:"application/json; charset=utf-8",
            data:JSON.stringify(data),
            success:function(data) {
                if(data) {
                    parent.tips(1, "保存成功！");
                    fn.call();
                }else{
                    parent.tips(0, "保存信息失败！");
                }
            },
            error:function(e){
                parent.tips(0,e);
            }
        });

    }

</script>

</body>
</html>